<template>
	<div id="app">
		<div style="height: 20px;display:flex;align-items: center;">
			<span style="height: 20px;line-height: 20px;font-size: 20px;margin-bottom: 20px;">查看所有用户设备</span>
		</div>
		<template>
			<el-table :data="tableData" border style="width: 100%">
				<el-table-column fixed label="序号" type="index" width="50">
				</el-table-column>
				<el-table-column prop="ueId" label="用户设备ID" width="180">
				</el-table-column>
				<el-table-column prop="equipmentId" label="设备id" width="180">
				</el-table-column>
				<el-table-column prop="peStatus" :formatter="stateFormat" label="用户设备运行状态">
				</el-table-column>
					<!-- 				<el-table-column prop="imageUrl" label="图片" width="200px">
					<template slot-scope="scope" v-if="scope.row.imageUrl">
						<el-image style="width: 160px; height: 80px"
							:src="require('@/assets/equipments/'+scope.row.imageUrl)"
							:preview-src-list="[require('@/assets/equipments/'+scope.row.imageUrl)]" />
					</template>
				</el-table-column> -->
					<el-table-column prop="peWorktime" label="设备工作时长(小时)">
						<template slot-scope="scope" >
							<div>
								<div>{{(scope.row.peWorktime/60).toFixed(1)}}</div>
							</div>
						</template>
					</el-table-column>
					<el-table-column prop="pePowerGeneration" label="用户设备累计发电量(度)">
						<template slot-scope="scope" v-if="scope.row.pePowerGeneration">
							<div>
								<div>{{scope.row.pePowerGeneration}}</div>
							</div>
						</template>
					</el-table-column>
					<el-table-column prop="peCreatetime" label="用户设备购买时间">
						<template slot-scope="scope">
							<div>
								<div>{{ scope.row.peCreatetime | formatDate }}</div>
							</div>
						</template>
					</el-table-column>

<!-- 					<el-table-column label="操作">
						<template slot-scope="scope">
							<el-button size="mini" @click.prevent="handleEdit(scope.$index, scope.row)">编辑</el-button>
							<el-button size="mini" type="danger" @click="handleDelete(scope.row)">删除</el-button>
						</template>
					</el-table-column> -->
			</el-table>
		</template>
	</div>
</template>

<script>
	//import request from '../utils/axios/request.js'
	import request from '@/utils/axios/request.js'
	export default {
		inject: ['reload'],
		data() {
			return {
				token: '',
				tableData: [{
					ueId: '',
					equipmentId: '',
					peStatus: '',
					peWorktime: '',
					peCreatetime: '',
					pePowerGeneration: ''
				}]
			}
		},
		methods: {
			stateFormat(row, column) {
				if (row.peStatus === true) {
					return '正常运行'
				} else {
					return '未运行'
				}
			},
			findimage(row) {
				console.log(row)
			},
		},
		created() {
			this.t = this.$cookies.get("token")
			// console.log(this.token)
			console.log(this.src)
			request({
					method: 'get',
					url: '/usersEquipments/allUsersEquipments',
					// headers: {
					// 	token: this.t
					// }
				})
				.then((res) => {
					console.log(res)
					var jsonObj = JSON.parse(JSON.stringify(res.data.data));
					this.tableData = jsonObj;
					console.log(this.tableData)
				})
			//console.log("创建成功")
		}
	}
</script>

<style scoped>
</style>